/**
 * Witontek.com.
 * Copyright (c) 2012-2016 All Rights Reserved.
 */
package test.java151.countDownLatch;

import java.util.Random;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

/**
 * 
 * @author Long
 * @version $Id: Runner.java, v 0.1 2016年12月29日 下午2:29:12  xiaolong.ma  Exp $
 */
public class Runner implements Callable<Integer> {

    private CountDownLatch begin;

    private CountDownLatch end;

    public Runner(CountDownLatch _begin, CountDownLatch _end) {
        begin = _begin;
        end = _end;
    }

    /** 
     * @see java.util.concurrent.Callable#call()
     */
    public Integer call() throws Exception {
        int score = new Random().nextInt(25);
        begin.await();
        TimeUnit.MILLISECONDS.sleep(score);
        end.countDown();
        return score;
    }

}
